﻿<%@ Page Title="询价与报价管理" Language="C#" MasterPageFile="~/masterPage/admin/Purchase.master"
    AutoEventWireup="true" CodeFile="PurchRefInquery.aspx.cs" Inherits="Trade_Events_event_grid" %>

<%@ MasterType VirtualPath="~/masterPage/admin/Purchase.master" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1">
    </telerik:RadAjaxLoadingPanel>    
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rpbNavigator">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rpbNavigator"></telerik:AjaxUpdatedControl>
                    <telerik:AjaxUpdatedControl ControlID="radGridMainlist" LoadingPanelID="RadAjaxLoadingPanel1">
                    </telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="radGridMainlist">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="radGridMainlist"></telerik:AjaxUpdatedControl>
                    <telerik:AjaxUpdatedControl ControlID="rpbNavigator" LoadingPanelID="RadAjaxLoadingPanel1">
                    </telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadDockLayout ID="RadDockLayout1" runat="server">
        <table>
            <tr>
                <td valign="top">
                    <telerik:RadPanelBar runat="server" ID="rpbNavigator" Width="200" ExpandMode="MultipleExpandedItems"
                        OnItemClick="rpbNavigator_ItemClick">
                        <Items>
                            <telerik:RadPanelItem Text="询价单" Expanded="True">
                                <Items>
                                    <telerik:RadPanelItem Text="全部询盘 qbxp" Value="All" Selected="true" />
                                    <telerik:RadPanelItem Text="待审核的询盘 dshxp" Value="UnApproval" />
                                    <telerik:RadPanelItem Text="待报价的询盘 dbjxp" Value="UnQuote" />
                                    <telerik:RadPanelItem Text="待授盘的询盘 dspxp" Value="UnAssigned" />
                                    <telerik:RadPanelItem Text="待反馈的询盘 dfkxp" Value="Feedback" />
                                </Items>
                            </telerik:RadPanelItem>
                            <telerik:RadPanelItem Text="紧迫商机" Expanded="True">
                                <Items>
                                    <telerik:RadPanelItem Text="今日到期询盘 jrdqxp" Value="ExpiredToday" />
                                    <telerik:RadPanelItem Text="明日到期询盘 mrdqxp" Value="ExpiredTomm" />
                                </Items>
                            </telerik:RadPanelItem>
                            <telerik:RadPanelItem Text="历史记录" Expanded="True">
                                <Items>
                                     <telerik:RadPanelItem Text="已报价的询盘 ybjxp" Value="Quoted" />
                                    <telerik:RadPanelItem Text="已授盘的询盘 yspxp" Value="Assigned" />
                                    <telerik:RadPanelItem Text="交易成功的询盘 jycgxp" Value="Successed" />
                                </Items>
                            </telerik:RadPanelItem>
                        </Items>
                    </telerik:RadPanelBar>
                </td>
                <td valign="top" width="800">
                    <telerik:RadDockZone ID="rdzContent" runat="server" BorderStyle="None">
                        <telerik:RadDock ID="rdContent" runat="server" Height="600" Title="我的询盘" CloseText="关闭"
                            CollapseText="收起" DefaultCommands="None" DockMode="Docked" ExpandText="展开" EnableRoundedCorners="true"
                            Collapsed="false" Resizable="false" Pinned="true" Width="600px" EnableDrag="false">
                            <ContentTemplate>
                                <telerik:RadGrid ID="radGridMainlist" AllowPaging="True" AllowSorting="True" DataSourceID="sdsInquiryList"
                                    runat="server" AllowFilteringByColumn="false" AutoGenerateColumns="False" AllowMultiRowSelection="true"
                                    OnItemCommand="radGridMainlist_ItemCommand">
                                    <PagerStyle FirstPageToolTip="首页" ShowPagerText="false" PagerTextFormat="{4}  当前{0}/{1}页, 条目({2}-{3})/{5}"
                                        NextPagesToolTip="下页" Mode="NextPrevAndNumeric" PageSizeLabelText="单页数目" PrevPageToolTip="上页"
                                        LastPageToolTip="末页" />
                                    <HierarchySettings ExpandTooltip="查看收到的报价单" CollapseTooltip="收起" />
                                    <MasterTableView DataKeyNames="InquiryID" ShowHeadersWhenNoRecords="true" NoMasterRecordsText="您尚未发布任何询盘">
                                        <DetailTables>
                                            <telerik:GridTableView runat="server" Width="100%" DataKeyNames="QuoteID" DataSourceID="sdsQuoteList"
                                                AllowPaging="false" AllowSorting="true" AllowMultiColumnSorting="false" AllowFilteringByColumn="false"
                                                NoDetailRecordsText="暂无报价单">
                                                <ParentTableRelation>
                                                    <telerik:GridRelationFields DetailKeyField="InquiryID" MasterKeyField="InquiryID" />
                                                </ParentTableRelation>
                                                <Columns>
                                                    <telerik:GridBoundColumn SortExpression="CompanyName" HeaderText="供应商名称" HeaderButtonType="LinkButton"
                                                        DataField="CompanyName" UniqueName="CompanyName">
                                                    </telerik:GridBoundColumn>
                                                    <telerik:GridTemplateColumn UniqueName="Quantity" Groupable="False" HeaderText="数量">
                                                        <HeaderStyle Width="75px"></HeaderStyle>
                                                        <ItemStyle Height="35px"></ItemStyle>
                                                        <ItemTemplate>
                                                            <asp:Literal ID="ltlQuantity1" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity1") %>'
                                                                runat="server"></asp:Literal><br />
                                                            <asp:Literal ID="ltlQuantity2" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity2") %>'
                                                                runat="server"></asp:Literal><br />
                                                            <asp:Literal ID="ltlQuantity3" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity3") %>'
                                                                runat="server"></asp:Literal>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn UniqueName="TotalAmount" Groupable="False" HeaderText="总价">
                                                        <HeaderStyle Width="75px"></HeaderStyle>
                                                        <ItemStyle Height="35px"></ItemStyle>
                                                        <ItemTemplate>
                                                            <asp:Literal ID="ltlAmount1" Text='<%# DataBinder.Eval(Container.DataItem, "TotalAmount").ToString().Split("|".ToCharArray())[0] %>'
                                                                runat="server"></asp:Literal><br />
                                                            <asp:Literal ID="ltlAmount2" Text='<%# DataBinder.Eval(Container.DataItem, "TotalAmount").ToString().Split("|".ToCharArray())[1] %>'
                                                                runat="server"></asp:Literal><br />
                                                            <asp:Literal ID="ltlAmount3" Text='<%# DataBinder.Eval(Container.DataItem, "TotalAmount").ToString().Split("|".ToCharArray())[2] %>'
                                                                runat="server"></asp:Literal>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn UniqueName="QuoteStatus" Groupable="False" HeaderText="状态">
                                                        <HeaderStyle Width="75px"></HeaderStyle>
                                                        <ItemStyle Height="35px"></ItemStyle>
                                                        <ItemTemplate>
                                                            <asp:Literal ID="ltlInquiryStatus" Text='<%# (DataBinder.Eval(Container.DataItem, "QuoteStatus").ToString().Substring(2).StartsWith("0"))? "未读": "已读" %>'
                                                                runat="server"></asp:Literal>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridTemplateColumn UniqueName="Assign" Groupable="False" HeaderText="授盘">
                                                        <HeaderStyle Width="75px"></HeaderStyle>
                                                        <ItemStyle Height="35px"></ItemStyle>
                                                        <ItemTemplate>
                                                            <asp:LinkButton ID="lbtAssign" runat="server" Text="授盘" Visible='<%# EnableAssign(DataBinder.Eval(Container.DataItem, "QuoteStatus").ToString()) %>'
                                                                CommandName="Assign" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "QuoteStatus") %>'
                                                                CausesValidation="false" />
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                </Columns>
                                            </telerik:GridTableView>
                                        </DetailTables>
                                        <Columns>
                                            <telerik:GridClientSelectColumn Reorderable="False" UniqueName="ClientSelectColumn">
                                                <HeaderStyle Width="30px"></HeaderStyle>
                                            </telerik:GridClientSelectColumn>
                                            <telerik:GridButtonColumn Text="删除" CommandName="Delete" ButtonType="ImageButton" ConfirmTitle="删除" ConfirmText="确认您要删除该询盘吗？">
                                                <HeaderStyle Width="2%" />
                                            </telerik:GridButtonColumn>
                                            <telerik:GridTemplateColumn UniqueName="PartThumbnail" DataField="PartThumbnail"
                                                AllowFiltering="false" Groupable="False">
                                                <HeaderStyle Width="25px"></HeaderStyle>
                                                <ItemStyle Height="35px"></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:Image ID="imgPartThumbnail" runat="server" BorderWidth="0px" AlternateText="No Image" />
                                                    <!-- delete by jiang  ImageUrl='<--%# Page.ResolveUrl("~/Trade/files/img/" +(DataBinder.Eval(Container.DataItem, "PartThumbnail") == ""? "icon_noimage.jpg": DataBinder.Eval(Container.DataItem, "PartThumbnail"))）-> %>' 
                                        -->
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridBoundColumn UniqueName="PartName" SortExpression="PartName" HeaderText="零件名称"
                                                DataField="PartName">
                                                <HeaderStyle Width="80px"></HeaderStyle>
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn UniqueName="Quantity1" SortExpression="Quantity1" HeaderText="采购数量"
                                                DataField="Quantity1">
                                                <HeaderStyle Width="60px"></HeaderStyle>
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn UniqueName="Category" SortExpression="Category" HeaderText="工艺/零部件类别"
                                                DataField="Category">
                                                <HeaderStyle Width="100px"></HeaderStyle>
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn UniqueName="ExpireDate" SortExpression="ExpireDate" HeaderText="有效期限"
                                                DataField="ExpireDate" DataFormatString="{0:d}">
                                                <HeaderStyle Width="100px"></HeaderStyle>
                                            </telerik:GridBoundColumn>
                                            <telerik:GridTemplateColumn Groupable="False" AllowFiltering="false" UniqueName="QuoteCount"
                                                DataField="QuoteTotalCount" HeaderText="报价数量">
                                                <HeaderStyle Width="75px"></HeaderStyle>
                                                <ItemStyle Height="35px"></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lbtQuote" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "QuoteTotalCount") + "个报价/" + DataBinder.Eval(Container.DataItem, "UnReadQuoteCount") + "个未读报价" %>'
                                                        CommandName="ExpandCollapse" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn UniqueName="InquiryStatus" Groupable="False" HeaderText="询盘状态">
                                                <HeaderStyle Width="75px"></HeaderStyle>
                                                <ItemStyle Height="35px"></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:Literal ID="ltlInquiryStatus" Text='<%# (DataBinder.Eval(Container.DataItem, "InquiryStatus").ToString().StartsWith("0"))? "未读": "已读" %>'
                                                        runat="server"></asp:Literal>
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn UniqueName="ViewQuotes" Groupable="False">
                                                <HeaderStyle Width="50px"></HeaderStyle>
                                                <ItemStyle Height="35px"></ItemStyle>
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="lbtViewQuotes" runat="server" ToolTip="点击查看所有报价" CausesValidation="false"
                                                        Text="查看" CommandName="viewquotes" CommandArgument="~/Trade/Purchase/PurchDetail.aspx" />
                                                </ItemTemplate>
                                            </telerik:GridTemplateColumn>
                                        </Columns>
                                    </MasterTableView>
                                    <ClientSettings>
                                        <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" UseClientSelectColumnOnly="true" />
                                    </ClientSettings>
                                </telerik:RadGrid>
                            </ContentTemplate>
                        </telerik:RadDock>
                    </telerik:RadDockZone>
                </td>
            </tr>
        </table>
    </telerik:RadDockLayout>
    <asp:SqlDataSource ID="sdsInquiryList" runat="server" ConnectionString="<%$ ConnectionStrings:XunPanConnectionString %>"
        SelectCommand="SELECT * FROM [vw_XPInquiryDetail] WHERE CompanyID = @CompanyID" FilterExpression="{0}" >
        <FilterParameters>
            <asp:Parameter Name="Filter1" Type="String" />
        </FilterParameters>
        <SelectParameters>
            <asp:SessionParameter Name="CompanyID" DbType="Guid" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="sdsQuoteList" ConnectionString="<%$ ConnectionStrings:XunPanConnectionString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [vw_XPQuoteDetail] Where InquiryID = @InquiryID AND [QuoteStatus] LIKE '_1%'"
        runat="server">
        <SelectParameters>
            <asp:SessionParameter Name="InquiryID" SessionField="InquiryID" DbType="Guid" />
        </SelectParameters>
    </asp:SqlDataSource>
</asp:Content>
